﻿using System;
using BookiFramework.Abstracts.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BookiFramework.net45.Test.Security
{    
    public class CryptoUnitTestBase<T> where T:ICrypter
    {        
        public void TestCrypTextUsingBytes(ICrypter crypter)
        {
            //Arrange
            const string textToEncrypt = "I need 20.";
            
            //Act
            var cryptoBytes = crypter.Crypt(textToEncrypt);
            var stringDecrypt = crypter.Decrypt(cryptoBytes);
            
            //Assert
            Assert.AreEqual(stringDecrypt,textToEncrypt);
        }

        public void TestCrypTextUsingText(ICrypter crypter)
        {
            //Arrange
            const string textToEncrypt = "I need 20.";

            //Act
            var cryptostring = crypter.CryptToText(textToEncrypt);
            var stringDecrypt = crypter.Decrypt(cryptostring);

            //Assert
            Assert.AreEqual(stringDecrypt, textToEncrypt);
        }
    }
}
